using System;

namespace AbstractClassExample // 命名空间
{
    // 定义一个抽象类
    public abstract class Shape
    {
        // 抽象方法没有实现
        public abstract double Area();

        // 普通方法可以有实现
        public void Display()
        {
            Console.WriteLine("This is a shape.");
        }
    }

    // 派生类：矩形
    public class Rectangle : Shape
    {
        public double Width { get; set; }
        public double Height { get; set; }

        // 实现抽象方法
        public override double Area()
        {
            return Width * Height;
        }
    }

    // 派生类：圆形
    public class Circle : Shape
    {
        public double Radius { get; set; }

        // 实现抽象方法
        public override double Area()
        {
            return Math.PI * Radius * Radius;
        }
    }

    public class Program
    {
        public static void Main(string[] args)
        {
            Shape rectangle = new Rectangle { Width = 5, Height = 10 };
            Shape circle = new Circle { Radius = 7 };

            rectangle.Display(); // 输出: This is a shape.
            Console.WriteLine($"Rectangle Area: {rectangle.Area()}"); // 输出: Rectangle Area: 50

            circle.Display(); // 输出: This is a shape.
            Console.WriteLine($"Circle Area: {circle.Area()}"); // 输出: Circle Area: 153.93804002589985
        }
    }
}
